<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
	var userChoice = prompt("请输入剪刀、石头、布?");
	var computerChoice = Math.random();
	if (computerChoice < 0.34) {
		computerChoice = "石头";
		} else if(computerChoice <= 0.67) {
			computerChoice = "布";
		} else {
			computerChoice = "剪刀";
	}
	 document.write("电脑随机: " + computerChoice + "<br/><br/>");
 
	function compare(choice1,choice2){
    	if(choice1 === choice2){
       		 return "平局!";
   		 }else if(choice1 === "石头"){
       		 if(choice2 === "剪刀"){
           		 return "石头 赢";
        	}else{
           		 return "布 赢";
       		 }
    	}else if(choice1 === "布"){
        	if(choice2 === "石头"){
           		return "布 赢";
        	}else{
           	 	return "剪刀 赢";
        	}
    	}else if(choice1 === "剪刀"){
      		if(choice2 === "石头"){
            	return "石头 赢";
        	}else{
           	 	return "剪刀 赢"; 
            }       
    	}    
	}
		document.write(compare(userChoice,computerChoice));
</script>
</head>
<body>
	
</body>
</html>